package com.lx.constant.enums;

import com.lx.constant.consts.CommonConstant;
import com.lx.inter.condition.generator.IGenerator;
import com.lx.inter.condition.generator.impl.ConditionGeneratorHandler;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 条件关键字枚举
 *
 * @author lx
 * @create 2022/12/6 17:55
 **/
@Getter
@AllArgsConstructor
public enum ConditionKeyWordEnum {

    EMPTY(0, CommonConstant.EMPTY, ConditionGeneratorHandler.SIMPLE_CONDITION_GENERATOR),
    COMMA(0, CommonConstant.COMMA, ConditionGeneratorHandler.SIMPLE_CONDITION_GENERATOR),
    AND(0, " AND ", ConditionGeneratorHandler.SIMPLE_CONDITION_GENERATOR),
    NOT(0, " NOT ", ConditionGeneratorHandler.SIMPLE_CONDITION_GENERATOR),
    OR(0, " OR ", ConditionGeneratorHandler.OR_CONDITION_GENERATOR),

    IN(1, " %s IN ( %s ) ", ConditionGeneratorHandler.DEFAULT_CONDITION_GENERATOR),
    NOT_IN(1, " %s NOT IN ( %s ) ", ConditionGeneratorHandler.DEFAULT_CONDITION_GENERATOR),

    LIKE(1, " %s LIKE %s ", ConditionGeneratorHandler.LIKE_CONDITION_GENERATOR),

    EQ(1, " %s = %s ", ConditionGeneratorHandler.DEFAULT_CONDITION_GENERATOR),
    NE(1, " %s <> %s ", ConditionGeneratorHandler.DEFAULT_CONDITION_GENERATOR),
    GT(1, " %s > %s ", ConditionGeneratorHandler.DEFAULT_CONDITION_GENERATOR),
    GE(1, " %s >= %s ", ConditionGeneratorHandler.DEFAULT_CONDITION_GENERATOR),
    LT(1, " %s < %s ", ConditionGeneratorHandler.DEFAULT_CONDITION_GENERATOR),
    LE(1, " %s <= %s ", ConditionGeneratorHandler.DEFAULT_CONDITION_GENERATOR),

    IS_NULL(1, " %s IS NULL ", ConditionGeneratorHandler.SIMPLE_NAME_CONDITION_GENERATOR),
    IS_NOT_NULL(1, " %s IS NOT NULL ", ConditionGeneratorHandler.SIMPLE_NAME_CONDITION_GENERATOR),

    EXISTS(1, " EXISTS ( %s )", ConditionGeneratorHandler.EXISTS_CONDITION_GENERATOR),
    BETWEEN(1, "%s BETWEEN %s AND %s", ConditionGeneratorHandler.BETWEEN_AND_CONDITION_GENERATOR),
    ;

    /**
     * 条件级别
     */
    private final int grade;

    /**
     * 语句表达式
     */
    private final String formatEl;

    /**
     * 条件表达式生成器
     */
    private final IGenerator conditionGenerator;
}
